/**
*   \file   spheresegment.h
*   \author Dave Reid
*   \brief  Header file for checking for a collision between a Sphere and a line.
*/
#ifndef __EAGL_INTERSECT_SPHERELINE_H_
#define __EAGL_INTERSECT_SPHERELINE_H_

#include "../ClosestPoint/segmenttopoint.h"
#include "spherepoint.h"

namespace eagl
{

struct INTERSECT_RESULT_SPHERESEGMENT
{
    /// The position of intersection.
    vec3 intersectPos;
};

inline bool intersect_spheresegment(float sphereRadius, const vec3 &spherePosition,
                                 const vec3 &segmentStart, const vec3 &segmentEnd,
                                 INTERSECT_RESULT_SPHERESEGMENT *result = NULL)
{
    // TODO: Might be able to do something a little more efficient.
    vec3 closest = closestpoint_segmenttopoint(segmentStart, segmentEnd, spherePosition);

    return intersect_spherepoint(sphereRadius, spherePosition, closest);
}

}

#endif  // __EAGL_INTERSECT_SPHERELINE_H_